package com.spider.web;

import com.spider.util.LagouUtil;

public class LagouController extends BaseController {
	
	
	/**
	 * ?kd=Java&spc=1&pl=&gj=&xl=&yx=&gx=&st=&labelWords=&
	 * lc=&workAddress=&city=%E5%8C%97%E4%BA%AC&requestId=&pn=2
	 */
	/**
	 * ?kd=Java&spc=1&pl=&gj=&xl=&yx=&gx=&st=&labelWords=&
	 * lc=&workAddress=&city=%E5%8C%97%E4%BA%AC&requestId=&pn=3
	 */
	public void spider() {
		int total = 0;
		int pageNo = 1;
		while(true) {
			int size = LagouUtil.parseIndex(LagouUtil.fetchIndexHtml(pageNo++));
			if(size==0)
				break;
			else
				total += size;
		}
		renderJson(success("抓取成功, 共抓取"+total+"条"));
	}
	
	public static void main(String[] args) {
		new LagouController().spider();
	}

}
